#{extends 'OraganizationViewMainPage.html' /}
 #{set title:'Organization-' + organization.name /}


<script type="text/javascript">
    var typeUser="";
        $(function(){
            $('#Create_Entity').hide();
            $.getJSON("@{Application.getType()}",{'orgId':'${organization.id}'},function(data){
               if(data.res == "True"){
                   $('#Create_Entity').show();
               }
            });
        });
$(document).ready(function() {
	 $.getJSON(
				'@{Application.incrementViews()}',
				{
					'id' : '${organization.id}',
					'type':'organization'
				},

				function(data) {
					
					document.getElementById('numberofViews').innerHTML = data.res;
					document.getElementById('visibilities').value = data.privacy;

				}, 'json') 
				if(${canLeadOrg==true}){
					 javascript: getOrganizers('${organization.id}');
	                  document.getElementById("myLog").innerHTML="<a href=\"http://localhost:9000/userscontroller/logview?organizationId="+'${organization.id}'+"\" class=\"frame\">OrganizationLog</a>";
				} else {
					$('#restrictOrganizer').hide();
					 $('#makeOrganizationLead').hide();
					 $('#myLog').hide();
				}

});
     function createEntity() {
                if (document.getElementById("nameNewEntity").value.length < 3) {
                    alert('name req and atleast 3');
                } else {
                    //public static void addEntity(String entityName, long orgId, long ideaDeveloper) {
                    $.getJSON('@{Application.addEntity()}', {
                        'entityName' : document.getElementById("nameNewEntity").value,
                        'orgId' : '${organization.id}',
                        'ideaDeveloper' : -1
                    }, function(data) {
                        alert(data.res);
                    });
                }

            }
         function displayCreateDiv(){
        $('#createTopics').show();
       document.getElementById('createTopics').focus();
    }
      function displayCreateDiv2(topicId,topicTitle,topicDescription){
        $('#draftedTopicsDivDiv').show();
        document.getElementById('drafttopic_title').value=topicTitle;
         document.getElementById('drafttopic_descr').value=topicDescription;
         document.getElementById('draftTopicId').value=topicId;
       document.getElementById('draftedTopicsDivDiv').focus();
    }
    
    
    function displayCreateDivReq(title, description){
        $('#createTopics').show();
        document.getElementById('topic_title').value = title;
        document.getElementById('topic_descr').value = description;
        document.getElementById('createTopics').focus();
    }
         function publicrequest(){
        		$.getJSON('@{IdeaDeveloperFunctions.JoinPublicOrganization()}',
                                         {
        					'orgId' : '${organization.id}',
        					'ideaDevoloperId' : '${loggedUserId}'
        				},

        				function(data) {
        					location.reload(true);
        				}, 'json')
          }
function inn() {
		$("#LoadingArea").empty().html(
				'<img src="/public/images/ajax-loader-loading.gif" />');
		$.getJSON(

		'@{IdeaDeveloperFunctions.requestJoinOrganization()}',

		{
			'organizationName' : '${organization.name}',

			//'body' : document.getElementById("bodyofinvitation").value,

			'devoloperusername' : '${loggedInUserName}'

		},

		function(data) {
				$("#LoadingArea").empty().html();
			$("#resultsofRequest").empty().html(data.res);
			//alert(data.res);

		}, 'json')

		$('#JoinPressed').hide('slow');
		

	}
</script>


<script type="text/javascript">

	var freeze = 0;
	var follow = 0;
	// var a = [document.getElementById("star1"), document.getElementById("star2"), document.getElementById("star3"), document.getElementById("star4"), document.getElementById("star5")]

	function mouseonimage(id) {

		for ( var i = 0; i < 5; i++) {
			a[i].src = "..\\..\\..\\public\\images\\disabledstar.png";
		}

		for ( var i = 0; i < id; i++) {

			a[i].src = "..\\..\\..\\public\\images\\redstar.png";
		}

	}

	function mouseoutimage() {

		for ( var i = 0; i < 5; i++) {
			a[i].src = "..\\..\\..\\public\\images\\star.png";
		}

		for ( var i = freeze; i < 5; i++) {

			a[i].src = "..\\..\\..\\public\\images\\disabledstar.png";
		}
		

	}
	
	

	function visi(){
		
		 $.getJSON('@{Application.changeOrgVisibility()}', {
			'OrgId': '${orgId}' ,
			'visibility':document.getElementById("visibilities").value
			},function(data){
				alert(data.box);
						}); 
						
	}
	

	/* function resetstars(){

		for(var i = 0; i < 5; i++) {
			a[i].src = "..\\..\\..\\public\\images\\disabledstar.png";
		}

		freeze = 0;
	} */

	function loadRate() {
		
		$.getJSON('@{TopicIdeaController.getOrganizationRating()}', {'organizationId':'${orgId}'},function(data){
			document.getElementById("currentRating").innerHTML=data.result;

		});

		$.getJSON('@{TopicIdeaController.alreadyRatedOrganization()}', {
			'organizationId' : '${orgId}'
		}, function(data) {
			freeze = data.result;
			mouseoutimage();

		});

	}

	function rateOrganization(rating) {

		$.getJSON('@{TopicIdeaController.rateOrganization()}', {
			'rate' : rating,
			'organizationId' : '${orgId}'
		}, function(data) {

			freeze = data.result;
			mouseoutimage();
		});
		
		loadRate();

	}
        function createpostIdea() {

        if(checkIdeaValidationCreate()){
       var descr=document.getElementById("createDescr").value;
       var title=document.getElementById("createTitle").value;
       $.post("@{TopicIdeaController.createpostIdea()}", {'id':'${orgId}' ,"descr":descr,"title":title ,"whereIdeaExist":"org"},
  function(data){
 $("<li><a href=@{TopicIdeaController.checkAuthorizationToViewIdea()}?ideaId="+data.ideaId+">"+data.title+"</a></li>")
 .appendTo(document.getElementById("ideas"))
document.getElementById("createTitle").value="";
document.getElementById("createDescr").value="";
document.getElementById("ideatitleexp").innerHTML="Title Required";
document.getElementById("ideadescrexp").innerHTML="Description Required";
$('#newidea').fadeOut(1000);
}, "json");

}
        };


   function draftIdea() {
   if(checkIdeaValidationCreate()){
var descr=document.getElementById("createDescr").value;
var title=document.getElementById("createTitle").value;
       $.post("@{TopicIdeaController.draftIdea()}", {'id':'${orgId}' ,"descr":descr ,'title':title,'whereIdeaExist':"org"},
  function(data){
$("<li><a id="+"draftIdeaLink"+data.ideaId+" href='javascript:editdraft("+data.ideaId+",\""+data.title+"\",\""+data.description+"\")'>"+data.title+"</a></li>")
   .appendTo(document.getElementById("draftedIdeaList"));
document.getElementById("createTitle").value="";
document.getElementById("createDescr").value="";
document.getElementById("ideatitleexp").innerHTML="Title Required";
document.getElementById("ideadescrexp").innerHTML="Description Required";
$('#newidea').fadeOut(1000);
}, "json");

}
   };

   function slidedown(object) {
       $('#'+document.getElementById(object).id).slideDown();

};


function discard(div){
    if(div=='newIdea'){
 document.getElementById("createTitle").value="";
document.getElementById("createDescr").value="";
document.getElementById("ideatitleexp").innerHTML="Title Required";
document.getElementById("ideadescrexp").innerHTML="Description Required ";
$('#newidea').fadeOut(1000);
    }else{
    document.getElementById("drafttitle").value="";
document.getElementById("draftdescr").value="";
document.getElementById("drafttitleexp").innerHTML="";
document.getElementById("draftdescrexp").innerHTML="";
$('#editDraft').fadeOut(1000);
    }
     
 }


 function checkIdeaValidationCreate(){
     var title=document.getElementById("createTitle").value;
     var descr=document.getElementById("createDescr").value;
                if(title==null||title==""){
                    document.getElementById("ideatitleexp").innerHTML="Title required"
                }else{
                    if(title.indexOf("&")!=-1){
                         document.getElementById("ideatitleexp").innerHTML="Title can't contain &";
                    }else{
                        if(title.length>25){
                             document.getElementById("ideatitleexp").innerHTML="Title can't be more than 25 letters";
                        }else{
                     document.getElementById("ideatitleexp").innerHTML="" ;
                        }
                }
                }
                if(descr==null||descr==""){
                    document.getElementById("ideadescrexp").innerHTML="Description required"

                }else{
                     if(descr.indexOf("&")!=-1){
                         document.getElementById("ideadescrexp").innerHTML="Description can't contain &";
                    }else{
                     document.getElementById("ideadescrexp").innerHTML="" ;
                }
                }

if(document.getElementById("ideadescrexp").innerHTML=="" && document.getElementById("ideatitleexp").innerHTML==""){
    return true
}
else{
    return false;
}

         }

function editdraft(ideaId,ideaTitle,ideaDescription){
    $('#editDraft').show();
    $('#editDraft').focus();
    document.getElementById('ideaid').value=ideaId;
              document.getElementById('drafttitle').value=ideaTitle;
              document.getElementById('draftdescr').value= ideaDescription;
               $(document.getElementById("draftIdeaLink"+ideaId)).remove();
}



  function postDraftIdea(ideaId){
               if(checkIdeaValidationDraft()){
              var title=document.getElementById("drafttitle").value;
                  var descr=document.getElementById("draftdescr").value;

                 $.post("@{TopicIdeaController.postDraftIdea()}",
                 {'ideaId':ideaId,'description':descr,'title':title
                      },
  function(data){

$("<li><a href=@{TopicIdeaController.checkAuthorizationToViewIdea()}?ideaId="+data.ideaId+">"+data.ideaTitle+"</a></li>")
 .appendTo(document.getElementById("ideas"))
   document.getElementById('draftdescr').value="";
   document.getElementById('drafttitle').value="";
   document.getElementById('drafttitleexp').innerHTML="";
   document.getElementById('draftdescrexp').innerHTML="";
  $('#editDraft').fadeOut(1000);
  },"json")
            }

           }


 function draftDraftIdea(ideaId){
     if(checkIdeaValidationDraft()){
              var title=document.getElementById("drafttitle").value;
                  var descr=document.getElementById("draftdescr").value;

                 $.post("@{TopicIdeaController.draftDraftIdea()}",
                 {'ideaId':ideaId,'description':descr,'title':title
                      },
  function(data){

$("<li><a id="+"draftIdeaLink"+data.ideaId+" href='javascript:editdraft("+data.ideaId+",\""+data.ideaTitle+"\",\""+data.ideaDescription+"\")'>"+data.ideaTitle+"</a></li>")
   .appendTo(document.getElementById("draftedIdeaList"));
   document.getElementById('draftdescr').value="";
   document.getElementById('drafttitle').value="";
   document.getElementById('drafttitleexp').innerHTML="";
   document.getElementById('draftdescrexp').innerHTML="";
  $('#editDraft').fadeOut(1000);
  },"json")
            }

 }



 function checkIdeaValidationDraft(){
     var title=document.getElementById("drafttitle").value;
     var descr=document.getElementById("draftdescr").value;
                if(title==null||title==""){
                    document.getElementById("drafttitleexp").innerHTML="Title required"
                }else{
                    if(title.indexOf("&")!=-1){
                         document.getElementById("drafttitleexp").innerHTML="Title can't contain &";
                    }else{
                        if(title.length>25){
                             document.getElementById("drafttitleexp").innerHTML="Title can't be more than 25 letters";
                        }else{
                     document.getElementById("drafttitleexp").innerHTML="" ;
                        }
                }
                }
                if(descr==null||descr==""){
                    document.getElementById("draftdescrexp").innerHTML="Description required"

                }else{
                     if(descr.indexOf("&")!=-1){
                         document.getElementById("draftdescrexp").innerHTML="Description can't contain &";
                    }else{
                     document.getElementById("draftdescrexp").innerHTML="" ;
                }
                }

if(document.getElementById("draftdescrexp").innerHTML=="" && document.getElementById("drafttitleexp").innerHTML==""){
    return true
}
else{
    return false;
}

         }






function showDuplicated(){
	if(document.getElementById("duplicatesShown?").value != "duplicatesShown"){
		showDuplicatedIdeas();
		document.getElementById("duplicatesShown?").value = "duplicatesShown";
		$(("#duplicateIdeas")).hide();
		$(("#duplicateIdeas")).slideDown(1000);
	} else {
		$(("#duplicateIdeas")).toggle(1000);
	}
}

function showDuplicatedIdeas(){
	var duplications = [];
	var singleDuplicate = [];
	var duplicateIdeasTitles = [];
	var infoOfIdea = [];
	$.getJSON('@{TopicIdeaController.showDuplicateIdeas()}',{'ID':${orgId},'type':'organization'},function(data){
	if(data.box.length != 0){
		duplications = data.box.split("$$");
		for(i = 0; i < duplications.length ; i++){
			singleDuplication = duplications[i].split("*$");
			sourceIdea = singleDuplication[0].split("!id#");
			document.getElementById("duplicateIdeas").innerHTML += "<div  id=\"Duplication"+sourceIdea[1]+"\" > </div><br>";
			document.getElementById("Duplication"+sourceIdea[1]+"").innerHTML += "<a onclick=\"showDuplicates('"+sourceIdea[1]+"')\">" + "Title: "+sourceIdea[0]+"" + "</a><br>";
			document.getElementById("Duplication"+sourceIdea[1]+"").innerHTML += "<a>" + "Description: "+sourceIdea[2]+"" + "</a><br>";
			document.getElementById("Duplication"+sourceIdea[1]+"").innerHTML += "<form id=\"Duplicates"+sourceIdea[1]+"\" style=\"border: 2px solid gray;\"> </form>";
			duplicateIdeasTitles = singleDuplication[1].split("$*");
			var k = 0;
			var duplicateIdeasIDS = [];
			while(k < duplicateIdeasTitles.length){
				infoOfIdea = duplicateIdeasTitles[k].split("!id#");
				//alert("<input type=\"checkbox\" id=\"DuplicateIdea"+(j+1)+"\" value=\""+infoOfIdea[1]+"\" />" + ""+infoOfIdea[0]+"");
				document.getElementById("Duplicates"+sourceIdea[1]+"").innerHTML += "<input type=\"checkbox\" name=\"duplicate\" value=\""+infoOfIdea[1]+"\" />";
				document.getElementById("Duplicates"+sourceIdea[1]+"").innerHTML += "<a  id=\"DuplicateIdea"+infoOfIdea[1]+"\" onclick=\"javascript:toggleDescription('"+infoOfIdea[1]+"')\">" + ""+infoOfIdea[0]+"" + "</a><br>";
				document.getElementById("Duplicates"+sourceIdea[1]+"").innerHTML += "<a  id=\"DuplicateIdeaDescription"+infoOfIdea[1]+"\">" + "Description: "+infoOfIdea[2]+"" + "</a> <br><br>";
				$(("#DuplicateIdeaDescription"+infoOfIdea[1]+"")).hide();
				k ++;
			}
			document.getElementById("Duplicates"+sourceIdea[1]+"").innerHTML += "<input type=\"button\" value=\"Merge with "+sourceIdea[0]+"\" id=\""+"Merge"+sourceIdea[1]+"\" onclick=\"javascript:mergeIdea('"+sourceIdea[1]+"')\" />";
			$(("#Duplicates"+sourceIdea[1]+"")).hide();
		} 
	} else {
		document.getElementById("duplicateIdeas").innerHTML += "<a>  No Duplicate Ideas  </a><br>";
	}
	});
}

function toggleDescription(ID){
	$(("#DuplicateIdeaDescription"+ID+"")).toggle(1000);	
}

function mergeIdea(ID){
	if(document.getElementById("Duplicates"+ID+"").duplicate.length != null){
	for (var i=0; i < document.getElementById("Duplicates"+ID+"").duplicate.length; i++){
	   if (document.getElementById("Duplicates"+ID+"").duplicate[i].checked){
	      notifyDuplicateOwner(ID, document.getElementById("Duplicates"+ID+"").duplicate[i].value);
		   deleteIdea(document.getElementById("Duplicates"+ID+"").duplicate[i].value);
	    }
   	}
	} else {
		if(document.getElementById("Duplicates"+ID+"").duplicate.checked){
			//alert(document.getElementById("Duplicates"+ID+"").duplicate.value);
			notifyDuplicateOwner(ID, document.getElementById("Duplicates"+ID+"").duplicate.value);
			deleteIdea(document.getElementById("Duplicates"+ID+"").duplicate.value);
		}
	}
	$.getJSON('@{TopicIdeaController.removeDuplicatesRelation()}',{'ID':ID},function(data){});
	document.getElementById("duplicateIdeas").innerHTML = "";
	window.setTimeout("showDuplicatedIdeas()",100);
}

function notifyDuplicateOwner(source, duplicate){
	$.ajax({
		type: "POST",
		url: '@{TopicIdeaController.notifyDuplicateOwner}',
		data: {'id':source, 'id2':duplicate}
		});
}

function showDuplicates(id){
	$(("#Duplicates"+id+"")).toggle(1000);
}

function deleteIdea(ideaId){

    $.getJSON('@{TopicIdeaController.deleteIdea()}',{'ideaId':ideaId,'aloneOrNot':"notalone"},function(data){
        alert(data.x);
        //if(document.getElementById("bigideadiv"+ideaId)!=null){
        $(document.getElementById("bigideadiv"+ideaId)).remove();
        //}

	});

}

function deleteIdea(ideaId){

    $.getJSON('@{TopicIdeaController.deleteIdea()}',{'ideaId':ideaId,'aloneOrNot':"notalone"},function(data){
        alert(data.x);
        });
}


</script>

<script>
function showMembers(){
	if(document.getElementById("members").innerHTML==""){
		id = ${orgId};
		$.getJSON('@{BrowseController.browseMembersByCommunityCounter()}', {'orgId':id}, function(data) {
			var members = "";
			if(data.members != null){
				if(data.members != "-1"){
					var userNames = data.members.split('&&');
					for(var i = 0; i < userNames.length - 1; i = i+1){
						var user = userNames[i].split("-")[1];
						var id = userNames[i].split("-")[0];
						var community_counter = userNames[i].split("-")[2];
						members += "<a href=\"http://localhost:9000/UserProfile/OtherUserProfile?userId=" + id + "\">" + user + "</a> Community counter:"+ community_counter +"</br>";
						
					}
				} else {
					members += "No members to show";
				}
			}
			members += "<input type=\"button\" id=\"hideMembers\" value=\"Close!\" onclick=\"$('#members').fadeOut(1000)\"/>"
			document.getElementById("members").innerHTML = members;
			$('#members').hide();
			$('#members').toggle(1000);
		});	
	} else {
		$('#members').toggle(1000);
	}
}
function showDraftedTopicDiv(){

$('#draftedTopicDiv').show();
}

function showDraftedIdeaDiv(){
$('#draftedIdeasDiv').show();
}
</script>

<script type="text/javascript">

function deleteOrganization() {
	alert("before");
	$.getJSON('@{Application.deleteOrganization()}', {
		'organizationId' : '${orgId}'
	}, function(data) {
		alert(data.deleteOrganization);
		window.location = "@{UserProfile.SelfUserProfile()}";
	});
}

function getOrganizers(orgID) {

	document.getElementById("organizers").innerHTML = "";

	$
			.getJSON(
					'@{Application.getAllOrganizers()}',
					{
						'orgID' : '${organization.id}'
					},
					function(data) {

						s = data.res.split("*");
                        if(s[1].length>0)
                        	{
						var total = "<p><label>Choose organizer to promote</label><select id=\"org\">"
						for ( var i = 1; i < s.length; i = i + 1) {
							if (s[i] != "") {
								total += "<option selected value="+i+">"
										+ s[i] + "</option>"
							}
						}
						total += "</select></p>";
						document.getElementById("organizers").innerHTML = total;
                        	}
                        else{$('#restrictOrganizer').hide();
                        $('#makeOrganizationLead').hide();
                        document.getElementById("label").innerHTML="<label>no organizaer that can be promoted to organization lead</label>";
                        }
					});

}

function resOrganizers(orgID) {

	var index = document.getElementById("org").selectedIndex
	var organizerUsername = document.getElementById("org").options[index].text
	var label ="";
	if (organizerUsername) {
		$.getJSON('@{Application.makeOrganizationLead()}', {
			'orgID' : '${organization.id}',
			'organizerUsername' : organizerUsername
		}, function(data) {

			javascript: getOrganizers('${organization.id}');
		    
		    label="<label>"+organizerUsername+" is now Organization Lead on Oragnization : "+data.org+"</label>";
		    document.getElementById("label").innerHTML=label;
		});

	}

}

</script>

<body onLoad="javascript:buttonsChecks()">
	<div id="content">

	<input type="hidden" id="duplicatesShown?" value="duplicatesNotShown" />
		<div id="dividedContentContainer">
			<div id="infoSideBar">
				<h5>
					<span>Managers:</span>
				</h5>
				<ul class="blocklist" id="orgManagers">
					#{ifnot managers}
					<p>No Managers yet!</p>

					#{/ifnot} #{list items:managers, as: 'manager' }
					<li><a
						href="@{UserProfile.OtherUserProfile(manager.ideaDeveloper.id)}">${manager.ideaDeveloper.username}</a>
					</li> #{/list}
				</ul>
				<h5>
					<span>Creator:</span>
				</h5>
				<ul class="creator" id="orgCreator">

					<li><a
						href="@{UserProfile.OtherUserProfile(organization.creator.ideaDeveloper.id)}">${organization.creator.ideaDeveloper.username}</a>
					</li>
				</ul>
				</br>
                <h5><span>Average Rate: </span><span id="currentRating"></span></h5>
				
				<div id="rate">
					<a href="javascript:void(0)"> <img id="reset" height="17"
						src="../../../public/images/reset.png"
						onclick="rateOrganization(0)" 
					/></a> <a href="javascript:void(0)"><img id="star1" height="20"
						src="../../../public/images/disabledstar.png"
						onmouseover="mouseonimage(1)" onmouseout="mouseoutimage()"
						onclick="rateOrganization(1)" 
					/></a><a href="javascript:void(0)"><img id="star2" height="20"
						src="../../../public/images/disabledstar.png"
						onmouseover="mouseonimage(2)" onmouseout="mouseoutimage()"
						onclick="rateOrganization(2)" 
					/></a><a href="javascript:void(0)"><img id="star3" height="20"
						src="../../../public/images/disabledstar.png"
						onmouseover="mouseonimage(3)" onmouseout="mouseoutimage()"
						onclick="rateOrganization(3)" 
					/></a><a href="javascript:void(0)"><img id="star4" height="20"
						src="../../../public/images/disabledstar.png"
						onmouseover="mouseonimage(4)" onmouseout="mouseoutimage()"
						onclick="rateOrganization(4)" 
					/></a><a href="javascript:void(0)"><img id="star5" height="20"
						src="../../../public/images/disabledstar.png"
						onmouseover="mouseonimage(5)" onmouseout="mouseoutimage()"
						onclick="rateOrganization(5)" 
					/></a>

					<script>
						var a = [ document.getElementById("star1"),
								document.getElementById("star2"),
								document.getElementById("star3"),
								document.getElementById("star4"),
								document.getElementById("star5") ];

						loadRate();
					</script>
				</div>

			</div>
			<div id="infoContainer">
			#{if isLead}
			<a class="frame" id="chosen"
		href="@{OrganizationLeadFunctionalities.editOrganizationProfile(organization.name)}" id="${organization.id}" >Edit organization Info </a>
			#{if isCreator}
			<a href="#" id="chosen" onclick="javascript:deleteOrganization()" id="deleteOrg" > delete </a>

		
			#{/if}
			#{/if}
				<h2>${organization.name}</h2>
				<p>${organization.description}</p>
			    <p>website:<a href="http://${organization.website}" >${organization.website}</a></p>
				<p>telephone: ${organization.telephone}</p>
				
				<h3>#Views: <span id="numberofViews"> </span>  </h3>

		</div>
		
		#{if isLead}
		
			    <div id="visibility">
				<input type="submit" id="r" value="Change Visibility"
					onclick="visi()" /> 
					
					<select id="visibilities">
					<option>Public</option>
					<option>Private</option>
					<option>Secret</option>

				</select>
			
		</div>
		
		#{/if}
				</div>
						
			
		#{ifnot canview}
		 #{if requestSentBefore}

		<h5>you have sent a request before calm down and pray :)</h5>


		#{/if} 

		#{ifnot requestSentBefore}

			<div id="resultsofRequest">
				<p id="LoadingArea"></p>

			</div>

#{ifnot isSecret}
			<div class="sidebar"  id="JoinPressed">
				<h5>you are not a member of this organization try joining!</h5>
				<input  id="join_private_button" class="formbutton"  value="Request To Join" type="button" onclick="inn()";>
			</div>
#{/ifnot}
#{if isSecret}

				<p> This is a secret organization you can  only be invited to join..why you are here  <a href="@{UserProfile.SelfUserProfile()}" >gohome</a> </p>

		#{/if} 

		</div>

		#{/ifnot} 
		#{/ifnot} 
		#{if canview}
		<div id="borderedContainer">
			<h5>
				<span>Ideas:</span>
			</h5>
			<ul class="ideaslist" id="ideas">
			
			
			
				#{ifnot ideas}
				<p>No Ideas avaiable !</p>

				#{/ifnot} 
				#{list items:ideas, as: 'idea' }
				<li><a href="@{TopicIdeaController.checkAuthorizationToViewIdea(idea.id)}">${idea.title}</a></li> 
				#{/list}
				
				

			</ul>
           <input type="submit" id="createYourOwnIdea"
			 value="createYourOwnIdea"
			onclick="javascript:slidedown('newidea')" />

		<div id="newidea" style="display: none">
			Idea_Title:<br> <input type="text"  id="createTitle" name="newIdea"
                                              />  <label id="ideatitleexp">Title Required</label><br />

                        <p></p>
			Idea_Description:<br> <textarea id="createDescr"
                                                    name="newIdea" rows = "3" cols="30 max" ></textarea><label id="ideadescrexp">Description Required</label> <br />
                        <input
				type="submit" name="post" value="post"
				onclick="javascript:createpostIdea()" />
                        <input type="submit"
				name="draft" value="draft" onclick="javascript:draftIdea()" />
                        <input
				type="submit" name="discard" value="discard"
				onclick="javascript:discard('newIdea')" />
		</div>

	
		</div>
		<div id="borderedContainer">
			<h5>
				<span>Entities:</span>
			</h5>
			<ul class="blocklist" id="Entities">
				#{ifnot entites}
				<p>No entites avaiable !</p>

				#{/ifnot} #{list items:entites, as: 'entity' }
				<li><a href="@{Application.EntityView(entity.id)}">${entity.name}</a>
				</li> #{/list}
                                <div id="Create_Entity">
                                    <p>To Create New Entity :</p>
                                    <p><label>Enter The name here :</label><input id="nameNewEntity" type="text"/></p>
                                    <a href="#" onclick="createEntity()">Submit</a>

                                </div>
			</ul>
		</div>
		<div id="borderedContainer">
			<h5>
				<span>Topics:</span>
			</h5>
                     <Button id="createTopicLink"  style="display: none" onclick="javascript:displayCreateDiv()">CreateTopic</Button>

			<Button id="drafts" style="display: none"
				onclick="javascript:requestTopicDraft(0)">My Drafts</Button>
			<Button id="topReqBtn" class="formbutton" type="submit"
				onclick="javascript:requestTopic()" value="topicReuest"
				name="topicRequest">Request a Topic!</Button>
			<div id="topicrequest" style="display: none">
				<h1>Topic Title:</h1>
				<textarea id="topicTitleReq" cols="20" rows="1"
					style="text-align: left" value="">
                </textarea>
				<h1>Topic Body:</h1>

				<textarea  id="topicBodyReq" cols="50" rows="8"
					style="text-align: left" value="">
                </textarea>
				<br> </br>
				<Button class="formbutton" type="submit"
					onclick="javascript:sendReq()" value="send request"
					name="send Request">Send</Button>
				<Button class="formbutton" type="submit"
					onclick="javascript:draftButton()" value="send request"
					name="send Request">Save As Draft</Button>

				<Button class="formbutton" type="submit"
					onclick="javascript:discardButton()" value="send request"
					name="send Request">Discard</Button>
			</div>

			<Button id="topReqchkBtn" class="formbutton" type="submit"
				onclick="javascript:checkTopicReqs(0)">Check Topics
				Requests</Button>
			<div id="requests" style="display: none">No Requests are Here
				now !</div>
			<ul class="topiclist" id="Topics">
				#{ifnot topics}
				<p>No Topics yet! ,what about requesting one?</p>
				#{/ifnot} 
				#{list items:topics, as: 'topic' }
				<li><a
					href="@{TopicIdeaController.checkAuthorizationToViewTopic(topic.id)}">${topic.title}</a>
				</li>

				 #{/list}
				 	
				 

			</ul>
		</div>

		<div id="borderedContainer">
			<h5>
				<span>Members:</span>
			</h5>
			<ul class="blocklist" id="memebers">

				#{ifnot memebers}
				<p>No members yet!</p>
				#{/ifnot} 
				#{list items:memebers, as: 'memeber' }
				<li><a href="@{UserProfile.OtherUserProfile(memeber.id)}">${memeber.username}</a>
				</li> #{/list}
			</ul>
			<input type="submit" id="Share"	value="Show members with highest community counter" onclick="showMembers()" />
		</div>

	</div>
	<div class="sidebar">
		<ul>
			<li>
				<form>
			#{ifnot isLead}	
#{if isPublic}
#{ifnot isMemeber} 
<input  id="join_publicorg_button" class="formbutton" value="Join" type="button" onclick="javascript:publicrequest()";>
#{/ifnot} 

#{/if}
#{/ifnot} 

					<input id="follow" class="formbutton" type="button"
						onclick="followOrganization()" value="Follow" name="FollowButton" style="background-color:green;">
					<input id="unfollow" class="formbutton" type="button"
						onclick="unfollowOrganization()" value="Unfollow"
						name="UnfollowButton">

						<br> 
					<br>
						<input id="showDuplicatedButton"
				class="formbutton" type="button" value="Duplicated Ideas"
				onclick="javascript:showDuplicated()" style="display:none;"/>
		<br> 
		<br>
		<div id="duplicateIdeas"></div>
                <br>
                <input id="draftedIdeasButton"
				class="formbutton" type="button" value="show Drafted Idea"
				onclick="javascript:showDraftedIdeaDiv()" />

                <br>

		<br>
		<div id="draftedIdeasDiv" style="display:none">
<ul id="draftedIdeaList">
                    #{if draftedIdeas}
					<h5>
				<span>Drafted Ideas:</span>
			</h5>
					#{list items:draftedIdeas, as: 'draftedIdea' }
				<li><a id="draftIdeaLink${draftedIdea.id}" href="javascript:editdraft('${draftedIdea.id}','${draftedIdea.title}','${draftedIdea.description}')">${draftedIdea.title}</a></li>

				#{/list}
				#{/if}
</ul>
                </div>

 <br>
                <input id="draftedTopicsButton"
				class="formbutton" type="button" value="show Drafted Topics"
				onclick="javascript:showDraftedTopicDiv()" />

                <br>
		<br>
		<div id="draftedTopicDiv" style="display:none">

                    
                    <ul id="draftedTopicList">
                       
                    #{if draftedTopics}
				<h5>
				<span>Drafted Topics:</span>
                                </h5>
				#{list items:draftedTopics, as: 'draftedTopic' }
				<li><a id="draftTopicLink${draftedTopic.id}" href="javascript:displayCreateDiv2('${draftedTopic.id}','${draftedTopic.title}','${draftedTopic.description}')">${draftedTopic.title}</a></li>
				#{/list}
				#{/if}
                                </ul>

                   
                </div>
				</form>
				<h4>
					<span>Followers</span>
				</h4>
				<ul class="blocklist">
					#{ifnot followers}
					<p>No followers yet!</p>

					#{/ifnot} #{list items:followers, as: 'follower' }
					<li><a href="@{UserProfile.OtherUserProfile(follower.id)}">${follower.username}</a>

					</li> #{/list}

				</ul>
			</li>

			<li>
				<h4>Tag Cloud</h4>

				<ul>
					<li>
						<p style="margin: 0;">Creative perfective finance students
							elections code SE ROCKS SO HARD</p>
					</li>
				</ul>
			</li>

			<li>
			<li>

				<h4>Latest Log updates</h4>
				<ul class="blocklist">
					<li><a href="#">karim has created a new entity </a></li>
					<li><a href="#">Ahmed has hidden topic Met</a></li>
					<li><a href="#">mohammed has added Ali as a friend</a></li>

				</ul>

			</li>
			<li>#{/if}
	</div>
	<div id="members" style="display: none" class="white_content"></div>

        <div id="editDraft" style="display: none" class="white_content">

			<input type="hidden" id="ideaid" name="ideaId" />
                 Idea_Title : <input type="text"
                            id="drafttitle" name="newIdea" /><label id="drafttitleexp"></label>
                 <br>

             Idea_Description :

             <textarea
                            id="draftdescr" name="newIdea" rows = "3" cols="30 max" ></textarea><label id="draftdescrexp"></label>
                       <br>
                       <br>
                            <input type="submit" name="post"
				value="post"
				onclick="javascript:postDraftIdea(document.getElementById('ideaid').value)" />
			<input type="submit" name="draft" value="draft"
				onclick="javascript:draftDraftIdea(document.getElementById('ideaid').value)" />
			<input type="submit" name="discard" value="discard"
				onclick="discard('editDraft')" />
     
		</div>

		        		
           	<form name="input" action="#" method="get">	
			<a id="makeOrganizationLead" href='#' onclick="javascript:resOrganizers()"> Make
				Organization Lead</a></form>

	        	<div id="organizers"></div>
	          <div id="label"></div> 
	          <div id="myLog"></div>
              
</body>
		  
     
